#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QThread>
#include <opencv2/opencv.hpp>

#include <OpenNI.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace openni;
using namespace cv;
using namespace std;


QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
enum IMG_TYPE
{
    DEPTH,
    COLOR,
    DR
};

class camerathread;
class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void startcamera();
    void stopcamera();
    void depthimageactive();
    void colorimageactive();
    void cameraprocess();


private slots:
    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

    void on_pushButton_3_clicked();
    void ondatachange();
    void on_checkBox_fit_clicked();

private:
    Ui::MainWindow *ui;
    bool isopen;
    IMG_TYPE imgtype;
    camerathread* mycamera;
    cv::Mat cvimage;
    int decX,decY;
};
class camerathread:public QThread
{
    Q_OBJECT
public:
    camerathread(MainWindow *window):mainwindow(window)
    {

    }
    ~camerathread()
    {

    }
protected:
    void run() override
    {
        mainwindow->cameraprocess();
    }
private:
    MainWindow* mainwindow;
};

#endif // MAINWINDOW_H
